<html>
  <head>
    <title>Using Xpo.UpdateSchema</title>
    <link rel="stylesheet" type="text/css" href="../../styles/presentation.css" />
    <link rel="stylesheet" type="text/css" href="ms-help://Hx/HxRuntime/HxLink.css" />
    <script type="text/javascript" src="../../scripts/EventUtilities.js"></script>
    <script type="text/javascript" src="../../scripts/SplitScreen.js"></script>
    <script type="text/javascript" src="../../scripts/Dropdown.js"></script>
    <script type="text/javascript" src="../../scripts/script_loc.js"></script>
    <script type="text/javascript" src="../../scripts/script_manifold.js"></script>
    <script type="text/javascript" src="../../scripts/script_feedBack.js"></script>
    <script type="text/javascript" src="../../scripts/CheckboxMenu.js"></script>
    <script type="text/javascript" src="../../scripts/CommonUtilities.js"></script>
  </head>
  <body>
    <input type="hidden" id="userDataCache" class="userDataStyle" />
    <input type="hidden" id="hiddenScrollOffset" />
    <img id="collapseImage" style="display:none; height:0; width:0;" src="../../icons/collapse_all.gif" title="Collapse image" />
    <img id="expandImage" style="display:none; height:0; width:0;" src="../../icons/expand_all.gif" title="Expand Image" />
    <img id="collapseAllImage" style="display:none; height:0; width:0;" src="../../icons/collapse_all.gif" />
    <img id="expandAllImage" style="display:none; height:0; width:0;" src="../../icons/expand_all.gif" />
    <img id="dropDownImage" style="display:none; height:0; width:0;" src="../../icon/dropdown.gif" />
    <img id="dropDownHoverImage" style="display:none; height:0; width:0;" src="../../icons/dropdownHover.gif" />
    <img id="copyImage" style="display:none; height:0; width:0;" src="../../icons/copycode.gif" title="Copy image" />
    <img id="copyHoverImage" style="display:none; height:0; width:0;" src="../../icons/copycodeHighlight.gif" title="CopyHover image" />
    <div id="header">
      <table id="topTable" cellspacing="0" cellpadding="0">
        <tr>
          <td>
            <span onclick="ExpandCollapseAll(toggleAllImage)" style="cursor:default;" onkeypress="ExpandCollapseAll_CheckKey(toggleAllImage, event)" tabindex="0">
              <img ID="toggleAllImage" class="toggleAll" src="../../icons/collapse_all.gif" />
              <label id="collapseAllLabel" for="toggleAllImage" style="display: none;">Collapse All</label>
              <label id="expandAllLabel" for="toggleAllImage" style="display: none;">Expand All</label>
            </span>
          </td>
        </tr>
      </table>
      <table id="bottomTable" cellpadding="0" cellspacing="0">
        <tr id="headerTableRow1">
          <td align="left">
            <span id="runningHeaderText">DevExpress Contrib</span>
          </td>
        </tr>
        <tr id="headerTableRow2">
          <td align="left">
            <span id="nsrTitle">
                  Using Xpo.UpdateSchema
               </span>
          </td>
          <td align="center" style="width: 1px; padding: 0px">
            <img src="../../images/DevExContrib 32.png" alt="DevExpress Contrib" />
          </td>
        </tr>
        <tr id="headerTableRow3">
          <td align="left">
            <span id="headfb" class="feedbackhead" />
          </td>
        </tr>
      </table>
      <table id="gradientTable">
        <tr>
          <td class="nsrBottom" background="../../icons/gradient.gif" />
        </tr>
      </table>
    </div>
    <div id="mainSection">
      <div id="mainBody">
        <div class="Content">
          <p>First define the schema updates that you would like to perform.</p>
          <p>When modifying the size of a string column you need to do absolutely nothing.
          Xpo.UpdateSchema will examine your existing database and the XPO Size attribute
          and modify those columns without any intervention on your part.</p>
          <p>To rename a column you would decorate the field or property with a RenameColumn
          attribute. The parameter identifies the previous name of the column.</p>
          <pre lang="cs" numberLines="true" outlining="true" title="Using the RenameColumn attribute">
   private int renameMe;
   [RenameColumn("OldColumnName")]
   public int RenameMe
   {
      get { return renameMe; }
      set { SetPropertyValue("RenameMe", ref renameMe, value); }
   }</pre>
          <p>To delete a column you would decorate the class with a DeleteColumn
          attribute. The parameter identifies the name of the column to be deleted.</p>
          <pre lang="cs" numberLines="true" outlining="true" title="Using the DeleteColumn attribute">
    [DeleteColumn("DeleteMe")]
    public class DeleteColumns : XPObject
    {
    }</pre>
          <p>All of the functionality of Xpo.UpdateSchema is accessed through an instance of the
          UpdateSchema class. Pass the connection string in the constructor of the UpdateSchema class.
          The connection string is the same one that you would use to connect an XPO DataLayer or Session.</p>
          <pre lang="cs" numberLines="true" outlining="true" title="Instantiating UpdateSchema">
   using(UpdateSchema updateSchema = new UpdateSchema(
      MSSqlConnectionProvider.GetConnectionString(
      "MyServerAndInstance", "MyDatabase")))
   {
      //...
   }</pre>
          <p>Next, call the UpdateSchema.Update method. Just like the Xpo.Session.UpdateSchema method,
          pass in the assembly, list of assemblies or list of types in which your persistent classes
          are contained.</p>
          <pre lang="cs" numberLines="true" outlining="true" title="Invoking the update with assemblies">
   bool result = updateSchema.Update(Assembly.GetAssembly(typeof(MyPersistentClass)));</pre>
          <pre lang="cs" numberLines="true" outlining="true" title="Invoking the update with types">
   bool result = updateSchema.Update(new Type[] { 
      typeof(MyPersistentClass), typeof(MyOtherPersistentClass) });</pre>
          <p>Xpo.UpdateSchema will process all of the modifications to your database as well as
          calling XPO to add new tables and columns to the persistent data store.</p>
          <p>&nbsp;</p>
          <p>
            <a href="Task-Based Help.html">Back to task-based help.</a>
          </p>
        </div>
      </div>
      <div id="footer">
        <div class="footerLine">
          <img width="100%" height="3px" src="../../icons/footer.gif" title="Footer image" />
        </div>
        <p />
        <div id="DevLynxVersion">
           <p><small>v2009.0.3332.39062 (2009-02-14  21:42:04)</small></p>
        </div>
        <div id="DevLynxCopyright">
           <p>Copyright &copy; 2008-2009, DevLynx</p>
        </div>
      </div>
    </div>
  </body>
</html>
<!-- @SortOrder 1 -->
